package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yixun.qfbao.api.service.SyncFollowAndAffixService;
import com.yixun.qfbao.apidto.SyncAffixReqDto;
import com.yixun.qfbao.apidto.SyncAffixResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.utils.TokenUtils;
import com.yixun.qfbao.vo.SyncAffixReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

@Service("receiveAffixHander")
public class ReceiveAffixHander extends CommonAbstractHander {
    private Logger logger = LoggerFactory.getLogger(ReceiveAffixHander.class);
    @Autowired
    SyncFollowAndAffixService syncFollowAndAffixService;
    
    @Autowired
    TokenUtils tokenUtils;
    
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<String> res = new BaseResponseDTO<String>();
        SyncAffixResDto resDto = new SyncAffixResDto();
        SyncAffixReqVo reqVo = (SyncAffixReqVo)reqDto;
        SyncAffixReqDto syncAffixReqDto = reqVo.getParams();
        resDto.setResult(ResultEnum.FAIL.getNo());
        try{
        	
            resDto = syncFollowAndAffixService.syncAffix(syncAffixReqDto);
            resDto.setResult(ResultEnum.SUCCESS.getNo());

        }catch (Exception e){
            logger.error("receive affix hander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setResult(e.getMessage());
        }
        res.setResult(resDto.getResult());
        res.setResData("success");
        return res;
    }
}
